9<template id="my_order">
	<div class="my_order">

		<!--头部-->
		<div class="about_header">

			<div class="about_title">
				<img src="../../assets/images/class/jiantou_03.png" @click.stop="back" />

				<p>我的订单</p>
				<div class="about_select">
					<div class="about_ing"></div>
				</div>

			</div>
		</div>
		<!--头部结束-->

		<!--用户地址/姓名-->
		<div class="my_order_name">

			<div class="my_order_self">
				<dl>
					<dt><img :src="logo.photo"/></dt>
					<dd>
						<h1>{{logo.name}}</h1>
						<div class="my_order_address">
							<p>{{addr}}</p>
							<img src="../../assets/images/my_order/my_order_07.png" @click.stop="key"/>
						</div>

					</dd>
				</dl>
			</div>

			<div class="my_order_dash"><img src="../../assets/images/my_order/my_order_11.png" /></div>

		</div>
		<!--用户地址/姓名结束-->

		<!--蜗牛瑜伽logo-->
		<div class="my_order_logo">

			<div class="my_order_price">
				<div class="logo"><img src="../../assets/images/my_order/my_order_15.png" /></div>
				<dl>
					<dt><img src="../../assets/images/my_order/my_order_logo.png"/></dt>
					<dd>
						<h1>{{logo.courseName}}</h1><span style="display:none;">{{logo.classid}}</span><span>{{logo.duration}}分钟</span>
						<div class="my_order_class">
							<p>一个课时</p><span>授课老师 :{{coachName}}</span></div>
						<div class="my_order_data">
							<p>{{dataMoney}} &nbsp;{{logo.date.date}}开始</p><span></span></div>
						<div class="my_order_money">
							<p><span>￥{{logo.price}}</span></p>
						</div>
					</dd>
				</dl>
			</div>

		</div>
		<!--蜗牛瑜伽logo结束-->
		<div class="my_order_each"></div>

		<!--优惠券/代金券-->
		<div class="my_order_cash">
			<div class="my_order_user">

				<div class="my_order_push">
					<p>优惠券/代金券</p>

					<!-- <span @click.stop="nextStep(userid,price)">
						{{sumber}}张可用
					</span> -->
					<span>
						{{sumber}}张可用
					</span>
				</div>
				<div class="my_order_vail">
					<p>优惠</p>
					<span><font>￥{{yuan.coupon_money}}</font></span>
				</div>

				<div class="my_order_vail">
					<p>总计</p>
					<!-- <span><font>￥{{price - coupon.coupon_money}}</font></span> -->
					<span><font id="num">￥{{logo.price - yuan.coupon_money}}</font></span>
					
				</div>

			</div>

		</div>

		<!--优惠券/代金券结束-->
		<!--订单已完成-->
		<div class="my_order_complete">
			<img src="../../assets/images/my_order/my_order_22.png" />

			<span>订单已生成</span>
		
		</div>

		<!--订单已完成结束-->

		<!--去支付-->
		<div class="my_order_pay">
			<div class="pay_money">
				<font>￥{{logo.price - yuan.coupon_money}}</font></div>
			<div class="pay_go" @click.stop="payGo(price,bookingid,couponid,create_time)">
				去支付
			</div>
		</div>
		<!--去支付结束-->

	</div>
</template>

<script>
	export default {
		data() {
			return {
				dataMoney:this.$route.query.dataMoney,
				addr:'',
				sessionid: '',
				coachid:this.$route.query.coachid,
				userid: "",
				coachName:'',
				photo:'',
				address: '',
				time: '',
				date: '',
				price: '',
				qian:'',
				gender:"",
				sumber:'',
				classid:'',
				duration:'',
				coupon:[],
				bookingid:'',
				create_time:'',
				couponid:'',
				order: [{
					name: '',
					coachid: '',
				}],
				logo:'',
				myorder:[],
				couponM:this.$route.query.coupon_money,
				userid:'',
				yuan:10,
				
			}
		},
		mounted() {
			this.outTime()
			this.num()
			   let _this = this
			//    let SESSION_ID = JSON.parse(window.sessionStorage.getItem('SESSION_ID'));
				var SESSION_ID=JSON.parse(window.localStorage.getItem('sessiond'))
				// console.log(SESSION_ID.user.head_image)
				_this.photo = SESSION_ID.user.head_image
				let obj = {
					//请求的参数
					userid: SESSION_ID.user.id,
					photo:SESSION_ID.user.head_image
					
				};
				// console.log(obj)
				_this.userid = obj.userid
			
				  

				let qs = require('qs');
				_this.$axios.post("http://yogahome.top/yujia/user/findValidCouponByUser", qs.stringify(obj), {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
					//重写headers 请求头  qs.stringify(json对象) 把对象转化为字符串 
				}).then(function(response) {
					// console.log(response)
					if(response.data.data ==null){
						let json = {
							'coupon_money': 0,
						};
						_this.coupon = json;
						_this.yuan = json;
					}else{
						let json = {
							'coupon_money': 10,
						};
						_this.coupon = json;
						_this.yuan = json;
					}
					_this.sumber = 0;
					_this.order = response.data.data;
                    _this.photo = SESSION_ID.user.head_image,
					_this.address = _this.$route.query.address
					_this.courseName = _this.$route.query.courseName
					_this.time = _this.$route.query.time
					_this.date = _this.strToTime(_this.$route.query.date);
					_this.price = _this.$route.query.price
					_this.coupon = response.data.data
					_this.sumber = _this.coupon.length;
					
					
					
					_this.coupon = response.data.data[0];
					_this.couponid = response.data.data[0].id
					console.log(_this.couponid);
					
				}).catch(function(error) {
					// console.log(error);
				});
		},
		created() {
		
		},
	   beforeUpdate(){
            this.cou()
			this.sel()
			var num =JSON.stringify({price:this.logo.price,'coupon':this.yuan.coupon_money})
				window.localStorage.setItem('num',num)
	   },
		methods: {

			num:function(){
				
			},
			sel:function(){
			   //let SESSION_ID = JSON.parse(window.sessionStorage.getItem('SESSION_ID'));
			    var SESSION_ID=JSON.parse(window.localStorage.getItem('sessiond'))
				let obj = {
					bookingid: this.$route.query.bookingid,
					photo:SESSION_ID.user.head_image,
				};
				
				let _this = this
				let qs = require('qs');
				this.$axios.post("http://yogahome.top/yujia/user/findOrderDetails", qs.stringify(obj), {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
				}).then(function(response) {
					
					_this.myorder = response.data.data
                    _this.bookingid = response.data.data.booking_id
                    _this.create_time = response.data.data.create_time
					_this.coachName = response.data.data.coach_name
					console.log(_this.coachName)
					
				}).catch(function(error) {
					console.log(error);
				});
			},
			cou:function(){
			
			//    let _this = this
			// //    let SESSION_ID = JSON.parse(window.sessionStorage.getItem('SESSION_ID'));
			// 	var SESSION_ID=JSON.parse(window.localStorage.getItem('sessiond'))
			// 	// console.log(SESSION_ID.user.head_image)
			// 	_this.photo = SESSION_ID.user.head_image
			// 	let obj = {
			// 		//请求的参数
			// 		userid: SESSION_ID.user.id,
			// 		photo:SESSION_ID.user.head_image
					
			// 	};
			// 	// console.log(obj)
			// 	_this.userid = obj.userid
			
				  

			// 	let qs = require('qs');
			// 	_this.$axios.post("http://yogahome.top/yujia/user/findValidCouponByUser", qs.stringify(obj), {
			// 		headers: {
			// 			'Content-Type': 'application/x-www-form-urlencoded'
			// 		}
			// 		//重写headers 请求头  qs.stringify(json对象) 把对象转化为字符串 
			// 	}).then(function(response) {
			// 		// console.log(response)
			// 		if(response.data.data ==null){
			// 			let json = {
			// 				'coupon_money': 0,
			// 			};
			// 			_this.coupon = json;
			// 			_this.yuan = json;
			// 		}else{
			// 			let json = {
			// 				'coupon_money': 10,
			// 			};
			// 			_this.coupon = json;
			// 			_this.yuan = json;
			// 		}
			// 		_this.sumber = 0;
			// 		_this.order = response.data.data;
			// 		_this.name = _this.$route.query.name
            //         _this.photo = SESSION_ID.user.head_image,
			// 		_this.address = _this.$route.query.address
			// 		_this.courseName = _this.$route.query.courseName
			// 		_this.time = _this.$route.query.time
			// 		_this.date = _this.strToTime(_this.$route.query.date);
			// 		_this.price = _this.$route.query.price
			// 		_this.coupon = response.data.data
			// 		_this.sumber = _this.coupon.length;
					
					
					
			// 		_this.coupon = response.data.data[0];
			// 		_this.couponid = response.data.data[0].id
					
			// 	}).catch(function(error) {
			// 		// console.log(error);
			// 	});
			},

            outTime:function(){
				var add=window.localStorage.getItem('add');
				this.addr=add
				var logos=JSON.parse(window.localStorage.getItem('logo'))
				this.logo = logos
				console.log(this.logo)
				
            },
			nextStep(userid) {				
				// let SESSION_ID = JSON.parse(window.sessionStorage.getItem('SESSION_ID'));
				  var SESSION_ID=JSON.parse(window.localStorage.getItem('sessiond'))
				 let obj = {
					//请求的参数
					userid:SESSION_ID.user.id,					
				};
				let _this = this
				let qs = require('qs');
				this.$axios.post("http://yogahome.top/yujia/user/findValidCouponByUser", qs.stringify(obj), {
					headers: {
						'Content-Type': 'application/x-www-form-urlencoded'
					}
					//重写headers 请求头  qs.stringify(json对象) 把对象转化为字符串 
				}).then(function(response) {
					
				}).catch(function(error) {
					// console.log(error);
				});
				var userid = Number(this.userid)

				this.$router.push({
					path: '/coupon',
					query: {
						status: '1',
						userid,
						// price,
					}
				})
				
			},
			back() {
				this.$router.push({
					path: '/appointment_coach',
					query: {
						coachid: this.$route.query.coachid

					}
				})
			},
			key(){
				this.$router.push({
					path: '/select_address',
					query: {
						coachid: this.$route.query.coachid

					}
				})
			},
			payGo(price,bookingid,couponid,create_time) {
				console.log(couponid)
				if(this.price ==null){
					// alert("请输入价格")
					
					
				}else{
					this.$router.push({
					path: '/pay',
					query: {
						yuan:this.yuan.coupon_money,
						coachid: this.$route.query.coachid,
						price:this.logo.price,
						bookingid:this.logo.bookingid,
						couponid:couponid,
						create_time,
					}
				})
				}
				
			}
		}
	}
</script>

<style scoped>
	@import "../../assets/css/my_order.css";
</style>